<template>
  <div class="community">
    <div class="community-content">
      <div class="community-content-suggestion">
        <div class="community-content-title">
          <p class="community-content-title-tip">优质建议</p>
          <img src="" alt="" />
        </div>
        <div class="community-content-suggest">
          <CommunitySuggest :getData="getData" :showStatus="false" :isAssist="false" />
        </div>
      </div>
      <div class="community-content-order">
        <div class="community-content-order-user">
          <div class="community-content-order-user-top">
            <img src="" alt="" />
            <div class="community-content-order-user-top-title">
              <p style="font-size:22px;color:#333;margin-bottom:10px;padding-top:12px">优质建议排行榜</p>
              <p style="font-size:14px;color:#9a9daf">TOP10</p>
            </div>
          </div>
          <div class="community-content-order-user-ine">
            <span>名次</span><span style="margin-left:120px;">用户名</span
            ><span style="margin-left:74px">获得奖励</span>
          </div>
          <div v-for="(item, index) in suggestions" :key="index" class="community-content-order-user-item">
            <div class="community-content-order-user-item-left" v-html="$options.filters.filterOrder(index)"></div>
            <div class="community-content-order-user-item-right">
              <div class="item-left"><img src="" />{{ item.name }}</div>
              <div class="item-right">+{{ item.rewardAmount }}贡献度</div>
            </div>
          </div>
        </div>
        <div class="community-content-order-rule">
          <div class="order-rule-title">贡献度规则</div>
          <div class="order-rule-content">
            贡献度规则贡献度规则贡献度规则贡献度规则贡献度规则贡献度规则贡献度规则贡献度规则贡献度规则贡献度规则贡献度规则贡献度规则贡献度规则贡献度规则贡献度规则贡献度规则贡献度规则
          </div>
          <a class="order-rule-detail" @click="() => (ruleDetail = true)">查看完整规则</a>
        </div>
      </div>
    </div>
    <a-modal
      v-model="ruleDetail"
      title="Vertically centered modal dialog"
      width="692px"
      height="480px"
      :mask="false"
      class="rule-detail-model"
      :footer="null"
    >
      <p class="rule-detail-model-title">贡献度规则</p>
      <p class="rule-detail-model-content">
        这里是贡献规则这里是贡献规则这里是贡献规则这里是贡献规则这里是贡献规则，这里是贡献规则这里是贡献规则这里是贡献规则这里是贡献规则这里是贡献规则。这里是贡献规则这里是贡献规则，这里是贡献规则这里是贡献规则，这里是贡献规则这里是贡献规则。这里是贡献规则这里是贡献规则，这里是贡献规则这里是贡献规则。这里是贡献规则这里是贡献规则这里是贡献规则，这里是贡献规则这里是贡献规则。这里是贡献规则。这里是贡献规则，这里是贡献规则这里是贡献规则这里是贡献规则这里是贡献规则。
      </p>
      <p class="rule-detail-model-content">
        这里是贡献规则这里是贡献规则这里是贡献规则这里是贡献规则这里是贡献规则，这里是贡献规则这里是贡献规则这里是贡献规则这里是贡献规则这里是贡献规则。这里是贡献规则这里是贡献规则，这里是贡献规则这里是贡献规则，这里是贡献规则这里是贡献规则。这里是贡献规则这里是贡献规则，这里是贡献规则这里是贡献规则。这里是贡献规则这里是贡献规则这里是贡献规则，这里是贡献规则这里是贡献规则。这里是贡献规则。这里是贡献规则，这里是贡献规则这里是贡献规则这里是贡献规则这里是贡献规则。
      </p>

      <div class="rule-detail-model-footer">
        <a-button @click="() => (ruleDetail = false)"> 知道了 </a-button>
      </div>
    </a-modal>
  </div>
</template>

<script>
import { suggestion } from '@/api/home'
import CommunitySuggest from '@/components/Account/CommunitySuggest'
export default {
  name: 'Community',
  components: {
    CommunitySuggest
  },
  filters: {
    filterOrder: function(value) {
      if (value < 3) {
        return `<span style="color: #fa7321;font-size:14px">TOP ${value + 1} </span>`
      } else {
        return value + 1
      }
    }
  },
  data() {
    return {
      suggestions: [],
      ruleDetail: false,
      currentPage: 1
    }
  },
  mounted() {
    this.getSuggestion()
  },
  methods: {
    getSuggestion() {
      const tmp = this
      suggestion({ typeList: ['2'], pageSize: '10', currentPage: '1', order: 'desc', statusList: ['4'] })
        .then(response => {
          for (const i of response.data) {
            tmp.suggestions.push({ name: i.name, rewardAmount: i.rewardAmount })
          }
        })
        .catch(function(error) {
          console.log(error)
        })
    },
    suggestionsProposal() {
      const tmp = this
      return new Promise((resolve, reject) => {
        suggestion({
          typeList: ['2'],
          pageSize: '4',
          currentPage: tmp.currentPage,
          order: 'desc',
          statusList: ['4']
        })
          .then(response => {
            tmp.currentPage = tmp.currentPage + 1
            resolve(response)
          })
          .catch(error => {
            reject(error)
          })
      })
    },
    getData(cab) {
      const { suggestionsProposal } = this
      cab(suggestionsProposal())
    }
  }
}
</script>

<style scoped lang="less">
.community {
  margin-top: 80px;
  margin-bottom: 104px;
  .community-content {
    width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    .community-content-suggestion {
      width: 820px;
      display: inline-block;
      margin-right: 20px;
      background-color: #fff;
      .community-content-title {
        height: 140px;
        width: 820px;
        background-color: #f6fbff;
        padding-left: 53px;
        padding-right: 75px;
        .community-content-title-tip {
          font-size: 34px;
          color: #333;
          width: 140px;
          height: 35px;
          line-height: 140px;
          display: inline-block;
        }
        img {
          width: 90px;
          height: 72px;
          display: inline-block;
          float: right;
          margin-top: 36px;
        }
      }
      .community-content-suggest {
        width: 100%;
        padding: 20px 30px 30px 30px;
      }
    }
    .community-content-order {
      width: 360px;
      display: inline-block;
      .community-content-order-user {
        background-color: #fff;
        height: 580px;
        width: 100%;
        .community-content-order-user-top {
          height: 88px;
          display: flex;
          margin-bottom: 10px;
          justify-content: flex-start;
          img {
            width: 96px;
            height: 80px;
            margin-top: 4px;
          }
          .community-content-order-user-top-title {
            width: 160px;
            margin-left: 20px;
          }
        }
        .community-content-order-user-ine {
          height: 40px;
          padding-left: 20px;
          paddding-right: 20px;
          color: #333;
          font-size: 14px;
          margin-bottom: 10px;
        }
        .community-content-order-user-item {
          padding-left: 20px;
          padding-right: 20px;
          heigth: 22px;
          line-height: 22px;
          &:not(:last-child) {
            margin-bottom: 20px;
          }
          display: flex;
          justify-content: flex-start;
          .community-content-order-user-item-left {
            width: 40px;
            text-align: center;
            margin-right: 66px;
            color: #9599ac;
            font-size: 16px;
          }
          .community-content-order-user-item-right {
            width: 214px;
            display: flex;
            justify-content: space-between;
            .item-left {
              font-size: 14px;
              color: #333;
              img {
                width: 22px;
                height: 22px;
                margin-right: 5px;
              }
            }
            .item-right {
              color: #fa7321;
              font-size: 13px;
            }
          }
        }
      }
      .community-content-order-rule {
        background-color: #fff;
        height: 240px;
        width: 100%;
        margin-top: 20px;
        padding-top: 20px;
        .order-rule-title {
          padding-left: 24px;
          border-left: solid 2px #33b0ed;
          height: 16px;
          width: 130px;
          line-height: 16px;
          font-size: 16px;
          color: #333;
        }
        .order-rule-content {
          margin: 20px 24px 29px 24px;
          width: 312px;
          height: 121px;
          font-size: 12px;
          line-height: 20px;
          letter-spacing: 0px;
          color: #5c5c5c;
        }
        .order-rule-detail {
          font-size: 14px;
          height: 14px;
          margin-left: 252px;
          margin-right: 24px;
          width: 312px;
          color: #373737;
        }
      }
    }
  }
}
.rule-detail-model {
  /deep/ .ant-modal-body {
    padding: 0px;
  }
  /deep/ .ant-modal-header {
    height: 120px;
    //background-image: url(../assets/image/home/banner.png);
    border-bottom: none;
    margin-bottom: 4px;
  }
  /deep/ .ant-modal-title {
    opacity: 0;
  }
  .rule-detail-model-title {
    font-size: 18px;
    color: #333;
    font-size: 400;
    text-align: center;
    margin-bottom: 26px;
    margin-top: 25px;
  }
  .rule-detail-model-content {
    font-size: 12px;
    color: #333;
    line-height: 24px;
    text-indent: 2em;
    margin-bottom: 0px;
    margin-left: 40px;
    margin-right: 40px;
  }
  .rule-detail-model-footer {
    margin-top: 20px;
    height: 72px;
    box-shadow: 0px -3px 7px 0px #f0f6ff;
    text-align: center;
    line-height: 72px;
    /deep/ .ant-btn {
      width: 120px;
      height: 36px;
      background-color: #33b0ed;
      border-radius: 2px;
      line-height: 32px;
      font-size: 16px;
      color: #fff;
      border: 1px solid #33b0ed;
    }
    /deep/ .ant-btn:hover,
    .ant-btn:focus {
      border-color: none;
    }
  }
}
</style>
